spendingFunction(alpha, t, param)
gsDesign()
are
alpha=0.025
for one-sided Type I error specification and
alpha=0.1
for Type II error specification.
However, this could be set to 1 ifspendfn
.param
.t
.gsDesign()
if the spending function is called from there.
Contains z-values for bounds of a design.gsDesign()
if the spending function is called from there.
Contains probabilities of boundary crossing at i
-th analysis for j
-th theta value
input to gsDesign()
in prob[i,j]
.spendfn
.
Normally a spending function will be passed to gsDesign()
in the parameter sfu
for the upper bound and
sfl
for the lower bound to specify a spending function family for a design.
In this case, the user does not need to know the calling sequence - only how to specify the parameter(s) for the
spending function.
The calling sequence is useful when the user wishes to plot a spending function as demonstrated below
in examples.
In addition to using supplied spending functions, a user can write code for a spending function.
See examples.gsDesign
, sfHSD
, sfPower
,
sfLogistic
, sfExponential
,
sfTruncated
,
Wang-Tsiatis Bounds, gsDesign package overview# Example 1: simple example showing what mose users need to know
# design a 4-analysis trial using a Hwang-Shih-DeCani spending function
# for both lower and upper bounds
x <- gsDesign(k=4, sfu=sfHSD, sfupar=-2, sfl=sfHSD, sflpar=1)
# print the design
x
# plot the alpha- and beta-spending functions
plot(x, plottype=5)
# Example 2: advance example: writing a new spending function
# Most users may ignore this!
# implementation of 2-parameter version of
# beta distribution spending function
# assumes t and alpha are appropriately specified (does not check!)
sfbdist <- function(alpha, t, param)
{
# check inputs
checkVector(param, "numeric", c(0, Inf), c(FALSE, TRUE))
if (length(param) !=2) stop(
"b-dist example spending function parameter must be of length 2")
# set spending using cumulative beta distribution and return
x <- list(name="B-dist example", param=param, parname=c("a", "b"),
sf=sfbdist, spend=alpha *
pbeta(t, param[1], param[2]), bound=NULL, prob=NULL)
class(x) <- "spendfn"
x
}
# now try it out!
# plot some example beta (lower bound) spending functions using
# the beta distribution spending function
t <- 0:100/100
plot(t, sfbdist(1, t, c(2, 1))$spend, type="l",
xlab="Proportion of information",
ylab="Cumulative proportion of total spending",
main="Beta distribution Spending Function Example")
lines(t, sfbdist(1, t, c(6, 4))$spend, lty=2)
lines(t, sfbdist(1, t, c(.5, .5))$spend, lty=3)
lines(t, sfbdist(1, t, c(.6, 2))$spend, lty=4)
legend(x=c(.65, 1), y=1 * c(0, .25), lty=1:4,
legend=c("a=2, b=1","a=6, b=4","a=0.5, b=0.5","a=0.6, b=2"))
Run the code above in your browser using DataLab